﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Shapes;
using Graphe.Collations;

namespace Graphe.Windows.Controls.Collations
{
    public class VerseControl : StackPanel
    {
        public Verse Verse { get; set; }

        public void Render()
        {
            TextBlock block = new TextBlock();

            Run versificationMarker = new Run(Verse.VersificationMarking);
            versificationMarker.Style = CollationsControlStylePicker.FindProperVersionResource("VersificationMarker") as Style;

            Run verse = new Run("  " + Verse.Text.Replace("\r\n", String.Empty).Replace("\t", String.Empty));
            verse.Style = CollationsControlStylePicker.FindProperVersionResource("VerseText") as Style;

            block.Inlines.Add(versificationMarker);
            block.Inlines.Add(verse);
            Children.Add(block);

            if (Verse.Variants.Count > 0)
            {
                VariantsControl variantsControl = new VariantsControl();
                variantsControl.Verse = Verse;
                variantsControl.Render();
                Children.Add(variantsControl);
            }

            if (Verse.NominaSacra.Count > 0)
            {
                NominaSacraControl nominaSacraControl = new NominaSacraControl();
                nominaSacraControl.NominaSacra = Verse.NominaSacra;
                nominaSacraControl.Render();
                Children.Add(nominaSacraControl);
            }
        }
    }
}
